# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :thread_local_storage.py
# @Time      :2025/7/7 23:40
# @Author    :aiyimu

import threading

# 创建线程局部数据
local_data = threading.local()

def show_data():
    print(f"{threading.current_thread().name}: {local_data.value}")

def thread_func(value):
    local_data.value = value
    show_data()

threads = []
for i in range(3):
    t = threading.Thread(target=thread_func, args=(i,), name=f"Thread-{i}")
    threads.append(t)
    t.start()

for t in threads:
    t.join()